package com.dyna.listener;

import com.dyna.foundation.domain.dto.SignReward;
import com.dyna.foundation.domain.event.SignRewardEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author zhoucaiwang
 * @date 2023/8/20
 */

@Slf4j
@Component
public class SignRewardEventListener {

    @Async
    @EventListener(value = SignRewardEvent.class)
    public void reward(SignRewardEvent event) {
        // 根据用户连续登录次数给予奖励
        SignReward signReward = event.getSignReward();
        log.info("用户【{}】连续登录{}天，已发送奖励", signReward.getUsername(), signReward.getCount());
    }

}
